import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { resolve } from 'path'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'

const pathResolve = dir => {
  return resolve(__dirname, ".", dir)
}

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  base:'./',
  resolve: {
    alias: {
      '@': pathResolve('src'),
      api: pathResolve('src/api/'),
      svgs: pathResolve('src/assets/svgs/'),
      imgs: pathResolve('src/assets/imgs/'),
      hooks: pathResolve('src/hooks'),
      components: pathResolve('src/components'),
      utils: pathResolve('src/utils')
    }
  },
  server: {
    port: 3669,
    open: true, 
    cors: true
  },
})
